<?php

class Model_Demo extends PhalApi_Model_NotORM
{

    protected function getTableName($id)
    {
    }

    public function demoList()
    {
        $list = DI()->notorm->demo->fetchAll();
        return $list;
    }

    public function demoAdd($data)
    {
        $list = DI()->notorm->demo->insert($data);
        return $list;
    }

    public function demoDel($id)
    {
        return DI()->notorm->demo->where('id='.$id)->delete();
    }

    public function addOpenID($openID)
    {
        $ret = DI()->notorm->user->where(array('openid'=>$openID))->fetch();

        if (empty($ret)){
            $data['openid']=$openID;
            $data['createtime']=time();
            $result = DI()->notorm->user->insert($data);
            return $result;
        }else{
            return array('code'=>'402','msg'=>'保存失败啦～');
        }
    }

    public function addFiles($url)
    {
        $ret = DI()->notorm->images->where(array('headsmall'=>$url))->fetch();

        if (empty($ret)){
            $data['headsmall']=$url;
            $data['createtime']=time();
            $result = DI()->notorm->images->insert($data);
            return $result;
        }else{
            return $ret;
        }
    }

}
